package
{
	import com.utils.CharUtilsMe;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	
	
	public class loadin extends Sprite
	{
		private var bit:Number = 0.5;
		private var sp:Sprite = new Sprite();
		private var _height:Number = 310;
		private var flog1:Boolean;
		private var flog2:Boolean;
		private var mask1:Sprite = new Sprite();
		private var mask2:Sprite = new Sprite();
		private var text1:TextField = new TextField();
		private var text2:TextField = new TextField();
		private var arr:Array = CharUtilsMe.charNumberArray("hello",1,20);
		private var brr:Array = CharUtilsMe.charNumberArray("hello",21,40);
		
		public function loadin()
		{
			sp.x=50;
			sp.y=50;
			this.addChild(sp);
			
			text1.height = _height;
			text1.wordWrap = true;
			
			text2.height = _height;
			text2.wordWrap = true;
			
			for (var i:int = 0; i < arr.length; i++) 
			{
				text1.htmlText += arr[i]+"登录游戏\n";
				text2.htmlText += brr[i]+"登录游戏\n";
			}
			
			draw(mask1);
			draw(mask2);
			text2.y = 108;
			text1.mask = mask1;
			text2.mask = mask2;
			
			flog1 = true;
			flog2 = false;
			
			sp.addChild(text1);
			sp.addChild(text2);
			sp.addChild(mask1);
			sp.addChild(mask2);
			this.addEventListener(Event.ENTER_FRAME,moveHandler);
		}
		
		private function draw(display:Sprite):void
		{
			display.graphics.beginFill(0xffffff);
			display.graphics.drawRect(0,0,100,108);
			display.graphics.endFill();
		}
		
		private function moveHandler(e:Event):void
		{
			if(flog1)
			{
				text1.y -= bit;
			}
			if(text1.y<-text1.height)
			{
				flog1 = false;
				text1.y = mask1.y + mask1.height;
			}
			if(text1.y<mask1.height-text1.height+10)
			{
				flog2 = true;
			}
			if(flog2)
			{
				text2.y -= bit;
			}
			if(text2.y<-text2.height)
			{
				flog2 = false;
				text2.y = mask2.y + mask2.height;
			}
			if(text2.y<mask2.height-text2.height+10)
			{
				flog1 = true;
			}
		}
	}
}